package com.front.managementfront.driver.controller;


        import com.alibaba.fastjson.JSON;
        import com.baomidou.mybatisplus.core.metadata.IPage;
        import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
        import com.front.managementfront.driver.entity.HktsRealNameAuthentication;
        import com.front.managementfront.driver.service.IHktsRealNameAuthenticationService;
        import com.hkts.management.common.vo.DriverListInfoVo;
        import com.front.managementfront.driver.vo.RealNameVo;
        import com.front.managementfront.utils.CustomPageUtils;
        import com.hkts.management.common.utils.CustomPage;
        import com.hkts.management.common.utils.Result;
        import com.hkts.management.common.utils.ResultUtil;
        import io.swagger.annotations.Api;
        import io.swagger.annotations.ApiOperation;
        import org.slf4j.Logger;
        import org.slf4j.LoggerFactory;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.web.bind.annotation.*;

        import java.text.ParseException;
        import java.util.List;
        import java.util.Map;

/**
 * @author yck
 * @since 2021-05-09
 */
@RestController
@RequestMapping("/front/hktsRealNameAuthentication")
@Api(tags = "司机信息管理")
public class HktsRealNameAuthenticationController {
    private final Logger logger = LoggerFactory.getLogger(HktsRealNameAuthenticationController.class);

    @Autowired
    public IHktsRealNameAuthenticationService iHktsRealNameAuthenticationService;

    /**
     * 分页查询数据
     *
     * @param page                       分页信息
     * @param hktsRealNameAuthentication 查询条件
     * @return
     */
    @ResponseBody
    @GetMapping("/getHktsRealNameAuthenticationPageList")
    public Result<Object> getHontUserList(Page<HktsRealNameAuthentication> page, HktsRealNameAuthentication hktsRealNameAuthentication) {
        return ResultUtil.data(CustomPageUtils.getCustomPage(iHktsRealNameAuthenticationService.selectPage(page, hktsRealNameAuthentication)));
    }

    /**
     * 保存和修改公用的
     *
     * @param hktsRealNameAuthentication 传递的实体
     * @return saveOrUpdate
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/hktsRealNameAuthenticationSave")
    public Result<Object> hktsRealNameAuthenticationSave(HktsRealNameAuthentication hktsRealNameAuthentication) {
        iHktsRealNameAuthenticationService.saveOrUpdate(hktsRealNameAuthentication);
        return ResultUtil.success("保存成功");
    }

    /**
     * 根据id获取对象
     *
     * @param id 实体ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/hktsRealNameAuthenticationGetById")
    public Result<Object> hktsRealNameAuthenticationGetById(String id) {
        HktsRealNameAuthentication byId = iHktsRealNameAuthenticationService.getById(id);
        return ResultUtil.data(byId);
    }

    /**
     * 根据id删除对象
     *
     * @param id 实体ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/hktsRealNameAuthenticationDelete")
    public Result<Object> hontUserDelete(String id) {
        iHktsRealNameAuthenticationService.removeById(id);
        return ResultUtil.success("删除成功");
    }

    /**
     * 批量删除对象
     *
     * @param item 实体集合ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/hktsRealNameAuthenticationBatchDelete")
    public Result<Object> deleteBatchIds(String item) {
        List<String> ids = (List<String>) JSON.parse(item);
        iHktsRealNameAuthenticationService.removeByIds(ids);
        return ResultUtil.success("删除成功");
    }

    /**
     * 根据userid 查询用户认证信息
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/hktsRealNameAuthenticationGetByUserId")
    @ApiOperation(value = "根据用户id获取用户认证信息")
    public Result<RealNameVo> hktsRealNameAuthenticationGetByUserId(String userId) {
        RealNameVo byId = iHktsRealNameAuthenticationService.getByUserId(userId);
        return ResultUtil.data(byId);
    }

    /**
     * 功能描述:
     * [userId]
     *
     * @return: com.hkts.management.common.utils.Result<java.lang.Object>
     * @Author: 杨春科
     * @Date: 2021-07-27 8:35
     * @Description //TODO
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/getDriverInfoPage")
    @ApiOperation(value = "获取pc端司机列表")
    public Result<CustomPage<DriverListInfoVo>> getDriverInfoPage(IPage<DriverListInfoVo> page, DriverListInfoVo vo) {
        CustomPage<DriverListInfoVo>  customPage= iHktsRealNameAuthenticationService.getDriverInfoPage(page,vo);
        return ResultUtil.data(customPage);
    }
    /** 功能描述:
    *基本信息
    * @return:
    * @Author: 杨春科
    * @Date: 2021-07-28 9:45
    * @Description //TODO
    */
    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/getDriverInfoByUserId")
    @ApiOperation(value = "根据用户id获取用户基本信息")
    public Result<DriverListInfoVo> getDriverInfoByUserId(String userId) throws ParseException {
        DriverListInfoVo  DriverListInfoVo= iHktsRealNameAuthenticationService.getDriverInfoByUserId(userId);
        return ResultUtil.data(DriverListInfoVo);
    }

    /** 功能描述:
     *基本信息
     * @return:
     * @Author: 杨春科
     * @Date: 2021-07-28 9:45
     * @Description //TODO
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/getDriverInfoByMobile")
    @ApiOperation(value = "根据用户手机号获取用户基本信息")
    public Result<Object> getDriverInfoByMobile(@RequestParam("mobile") String mobile) throws ParseException {
        return iHktsRealNameAuthenticationService.getDriverInfoByUserMobile(mobile);
    }
    /** 功能描述:
     *基本信息
     * @return:
     * @Author: 杨春科
     * @Date: 2021-07-28 9:45
     * @Description //TODO
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/getDriverInfosByMobile")
    @ApiOperation(value = "根据用户手机号获取用户列表基本信息")
    public Result<List<DriverListInfoVo>> getDriverInfosByMobile(@RequestParam("mobile") String mobile) throws ParseException {
        return iHktsRealNameAuthenticationService.getDriverInfosByUserMobile(mobile);
    }
    /** 功能描述:
    *  根据司机名称查找用户id
    * @return:
    * @Author: 杨春科
    * @Date: 2021-07-29 22:01
    * @Description //TODO
    */
    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/getIdsByDriverName/{driverName}")
    @ApiOperation(value = "根据用户名称获取用户id")
    public Result<List<String>> getIdsByDriverName(@PathVariable String driverName){
        List<String> list=iHktsRealNameAuthenticationService.getIdsByDriverName(driverName);
        return  ResultUtil.data(list);
    }
  /** 功能描述:
  *根据司机ids获取司机名称
  * @return:
  * @Author: 杨春科
  * @Date: 2021-08-09 10:21
  * @Description //TODO
  */
  @ResponseBody
  @RequestMapping(method = RequestMethod.GET, value = "/getDriverNamesByIds/{ids}")
  @ApiOperation(value = "根据用户id获取用户名称")
  public Result<Map<String,String>> getDriverNamesByIds(@PathVariable String ids){
    Map<String,String> map= iHktsRealNameAuthenticationService.getDriverNamesByIds(ids);
      return  ResultUtil.data(map);
  }
}
